import 'package:flutter/cupertino.dart';

class DelayShowWidget extends StatefulWidget {
  Widget? child;
  int delay = 0;
  bool isNeedDelay = false;
  DelayShowWidget({super.key, required this.child, required this.delay, required this.isNeedDelay});

  @override
  State<DelayShowWidget> createState() => _DelayShowWidgetState();
}

class _DelayShowWidgetState extends State<DelayShowWidget> {
  bool isShowState = false;
  @override
  void initState() {
    super.initState();
    isShowState = !widget.isNeedDelay;
    if (widget.isNeedDelay) {
      Future.delayed(Duration(seconds: widget.delay)).then((value) {
        setState(() {
          isShowState = true;
        });
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: isShowState ? widget.child : Container(),
    );
  }
}
